package com.heather.exam.service.impl;

import com.heather.exam.mapper.admin.StudentMapper;
import com.heather.exam.models.certificate.Student;
import com.heather.exam.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

    @Service
    public class StudentServiceImpl implements StudentService {
        @Autowired
        private StudentMapper studentMapper;

        @Override
        public String applyCertificate(int studentId, int passingScore) {
            Student student = studentMapper.getStudentById(studentId);

            if (student == null) {
                return "学生不存在";
            }

            if (student.getScore() >= passingScore) {
                studentMapper.updateCertificateStatus(studentId, true);
                return "恭喜你获得优秀学生称号！";
            } else {
                return "不满足证书申请条件";
            }
        }
    }

